package com.cti.commons.delayqueue.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * @author et.wang
 * @description: 线程池配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "delay.queue.threadpool")
public class ThreadPoolProperties {

    /**
     * 任务桶线程池
     */
    @Autowired
    private BucketPoolProperties bucketPool;

    /**
     * 消息消费线程池
     */
    @Autowired
    private CustomerPoolProperties customerPool;

    @Data
    @Component
    public static class BucketPoolProperties {

        private int corePoolSize = 2 * Runtime.getRuntime().availableProcessors();

        private int maxPoolSize = 2 * Runtime.getRuntime().availableProcessors() + 1;

        private int queueCapacity = 1000;

    }

    @Data
    @Component
    public static class CustomerPoolProperties {

        private int corePoolSize = 1 * Runtime.getRuntime().availableProcessors();

        private int maxPoolSize = 1 * Runtime.getRuntime().availableProcessors() + 1;

        private int queueCapacity = 1000;

    }

}
